
package GUI;
/**
 *  This class will manage the appearance of the panels on the frame
 *  this part of the GUI is incharge of setting all action events
 */

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.plaf.DimensionUIResource;
import Chat.ClientConsole;
import Chat.EchoServer;
import Control.*;
import Entity.*;

public class ScreenManager extends JFrame {

	private static final long serialVersionUID = 1L;
	final public static int DEFAULT_PORT = 2222;
	public static String ip;
	/** The only instance of the client (singleton) */
	private static ClientConsole client; 
	/** holds a flag for connection */
	//public static boolean isFirstTime = true;

	private static User userLogged;
	private static EchoServer sv;
	private LoginControl login;
	private MainControl main;
	private HendleCustomerControl handelCust;
	private UpdateWorkerDetailsControl updateWorker;
	private HandelWorkerControl handleWorker;
	private HandleEventControl handleEvent;
	private LogOutControl logOut;
	private HandleSchedule handleSchedule;
	private HandleMassage handleMassage;
	private HandelReport handelReport;
	
	
	public ScreenManager() {
		setTitle("ANS");

		setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/resources/camera.png")));
		
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
		  		try {
					client.cclient.closeConnection();
				} catch (IOException e1) {
					e1.printStackTrace();
				}
	    	System.exit(0);
			}
		});
		setMinimumSize(new Dimension(786, 525));
		setPreferredSize(new DimensionUIResource(786, 525));
		setResizable(false);
		setLocationRelativeTo(null);
		
		getConn();
		//calac = new Calendar();
		userLogged = new User();
		login = new LoginControl();
		logOut = new LogOutControl();
		main = new MainControl();
		updateWorker = new UpdateWorkerDetailsControl();
		handleWorker = new HandelWorkerControl();
		handelCust = new HendleCustomerControl();
		handleEvent = new HandleEventControl();
		handleSchedule = new HandleSchedule();
		handleMassage = new HandleMassage();
		handelReport = new HandelReport();
		
		getContentPane().add(login.getlogInPanel());
		setContentPane(login.getlogInPanel());
	    setVisible(true);
	    
		this.Action_listener_operations();
		
	
	}//end constructor
	private void getConn(){
		try {
			ip=(InetAddress.getLocalHost().getHostAddress());
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		getConnection(ip, DEFAULT_PORT);
		
	}
	/**
	 * main entry point for the screen manager
	 */
	public static void main(String[] args){
		 sv = new EchoServer(DEFAULT_PORT);
		 
		 
		 try 
		 {
		   sv.listen(); //Start listening for connections
		   
		 } 
		 catch (Exception ex) 
		 {
		   System.out.println("ERROR - Could not listen for clients!" + ex.getMessage());
		 }
		new ScreenManager();
	}
	
	/**
	 * set the action events for all the buttons in the program.
	 * when button is pressed a function from the control called
	 * and a screen change is made.
	 */
	/**
	 * 
	 */
	/**
	 * 
	 */
	public void  Action_listener_operations(){

		login.getlogInPanel().getSubButt().addKeyListener(new KeyAdapter() {
			public void keyPressed(KeyEvent arg0) {
				boolean s =login.loginReq_pressed();
				if(s==false){
					login.getlogInPanel().set_password("");
					login.getlogInPanel().set_userName("");
				}
				else{
					if(userLogged.getPrivilage().equals("Worker")){
						getContentPane().add(main.getWorkerMainGui());
						setContentPane(main.getWorkerMainGui());
					    setVisible(true);
						}
					else if(userLogged.getPrivilage().equals("Manager")){
						//calac.cl();
						handleMassage.getMsg();
						getContentPane().add(main.getManagerMainGui());
						setContentPane(main.getManagerMainGui());
					    setVisible(true);
					    
						}
					else if(userLogged.getPrivilage().equals("Secretary")){
						getContentPane().add(main.getSecMainGui());
						setContentPane(main.getSecMainGui());
					    setVisible(true);
						}
					}
			
			}
		});
		//login submit button pressed
		login.getlogInPanel().getSubButt().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean s =login.loginReq_pressed();
				if(s==false){
					login.getlogInPanel().set_password("");
					login.getlogInPanel().set_userName("");
				}
				else{
					if(userLogged.getPrivilage().equals("Worker")){
						getContentPane().add(main.getWorkerMainGui());
						setContentPane(main.getWorkerMainGui());
					    setVisible(true);
						}
					else if(userLogged.getPrivilage().equals("Manager")){
						//calac.cl();
						handleMassage.getMsg();
						getContentPane().add(main.getManagerMainGui());
						setContentPane(main.getManagerMainGui());
					    setVisible(true);
					    
						}
					else if(userLogged.getPrivilage().equals("Secretary")){
						getContentPane().add(main.getSecMainGui());
						setContentPane(main.getSecMainGui());
					    setVisible(true);
						}
					}
			
			}
		});
		/**
		 * manager pressed massage button
		 */
		main.getManagerMainGui().getBtnMassage().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(handleMassage.getMsgLenght()>0){
					handleMassage.setMsgNextWindow(0);
					handleMassage.setMsg1Gui();
					getContentPane().add(handleMassage.getMassageGui());
					setContentPane(handleMassage.getMassageGui());
				    setVisible(true);
				}
				else
					JOptionPane.showMessageDialog(null, "You have no masages today ", "Massage", JOptionPane.INFORMATION_MESSAGE);
			}
		});
		/**
		 * massage window next button was pressed
		 */
		handleMassage.getMassageGui().getBtnNext().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				handleMassage.setMsgNextWindow(handleMassage.getMsgNextWindow()+1);
				if(handleMassage.getMsgLenght()>handleMassage.getMsgNextWindow())
				{
					handleMassage.setMsg2Gui();
					getContentPane().add(handleMassage.getMsgGuiNext());
					setContentPane(handleMassage.getMsgGuiNext());	
				    setVisible(true);
				}				
			}
		});
		
		/**
		 * massage window next button was pressed
		 */
		handleMassage.getMsgGuiNext().getBtnNext().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				handleMassage.setMsgNextWindow(handleMassage.getMsgNextWindow()+1);
				if(handleMassage.getMsgLenght()>handleMassage.getMsgNextWindow())
				{
					handleMassage.setMsg1Gui();
					getContentPane().add(handleMassage.getMassageGui());
					setContentPane(handleMassage.getMassageGui());
				    setVisible(true);
				}		
			}
		});
		/**
		 *  massage window back button was pressed
		 */
		handleMassage.getMassageGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

				if(handleMassage.getMsgNextWindow()==0){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
				    setVisible(true);
				}
				else{
					handleMassage.setMsgNextWindow(handleMassage.getMsgNextWindow()-1);
					handleMassage.setMsg2Gui();
					getContentPane().add(handleMassage.getMsgGuiNext());
					setContentPane(handleMassage.getMsgGuiNext());
				    setVisible(true);	
				}
			}
		});
		/**
		 *  massage window back button was pressed
		 */
		handleMassage.getMsgGuiNext().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				handleMassage.setMsgNextWindow(handleMassage.getMsgNextWindow()-1);
				handleMassage.setMsg1Gui();
					
				getContentPane().add(handleMassage.getMassageGui());
				setContentPane(handleMassage.getMassageGui());
			    setVisible(true);	
			}
		});
		/**
		 * Worker main update details button pressed
		 */
		main.getWorkerMainGui().getBtnUpdateDetails().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				updateWorker.viewWorkerDetails();
				getContentPane().add(updateWorker.getUpdateWdetails());
				setContentPane(updateWorker.getUpdateWdetails());
			    setVisible(true);
			}
		});
		/**
		 * Worker main update password button pressed
		 */
		main.getWorkerMainGui().getBtnUpdatePassword().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
					getContentPane().add(updateWorker.getUpdateWpassword());
					setContentPane(updateWorker.getUpdateWpassword());
				    setVisible(true);
			}
		});
		/**
		 * Worker main view event button pressed
		 */
		main.getWorkerMainGui().getBtnViewEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(handleEvent.getEveData());
				setContentPane(handleEvent.getEveData());
				setVisible(true);
			}
		});
		/**
		 * Worker main view schedule button pressed
		 */
			main.getWorkerMainGui().getBtnViewSched().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				handleSchedule.getSchedule();
				getContentPane().add(handleSchedule.getScheduleGui());
				setContentPane(handleSchedule.getScheduleGui());
			    setVisible(true);
			}
		});
		/**
		 * Worker main logout button pressed
		 */
		main.getWorkerMainGui().getBtnLogout().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				//boolean ans = logOut.log_out_pressed();
			//	if(ans==true){
				    try {
						client.cclient.closeConnection();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
				//}									
			}
		});
		/**
		 * manager main logout button pressed
		 */
		main.getManagerMainGui().getBtnLOGOUT().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				boolean ans = logOut.log_out_pressed();
//				if(ans==true){
					try {
						client.cclient.closeConnection();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
				}											
			//}
		});
		/**
		 * secretary main logout button pressed
		 */
		main.getSecMainGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				boolean ans = logOut.log_out_pressed();
//				if(ans==true){
					try {
						client.cclient.closeConnection();
					} catch (IOException e1) {
						e1.printStackTrace();
					}
				}													
			//}
		});
		/**
		 * manager main handle worker button pressed
		 */
		main.getManagerMainGui().getBtnHandelWorker().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
						
				getContentPane().add(handleWorker.getHandleWorker());
				setContentPane(handleWorker.getHandleWorker());
			    setVisible(true);
			}
		});
		/**
		 * change worker password button pressed
		 */
		updateWorker.getUpdateWpassword().getBtnChange().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				boolean ans = updateWorker.changeWorkerPassword();
			
				updateWorker.getUpdateWpassword().getuName().setText("");
				updateWorker.getUpdateWpassword().getPass().setText("");
				updateWorker.getUpdateWpassword().getVerPass().setText("");	
				if(ans){
						if(userLogged.getPrivilage().equals("Worker"))
						{
							getContentPane().add(main.getWorkerMainGui());
							setContentPane(main.getWorkerMainGui());
						    setVisible(true);
						}
						if(userLogged.getPrivilage().equals("Manager"))
						{
							getContentPane().add(main.getManagerMainGui());
							setContentPane(main.getManagerMainGui());
						    setVisible(true);
						}
						if(userLogged.getPrivilage().equals("Secretary"))
						{
							getContentPane().add(main.getWorkerMainGui());
							setContentPane(main.getWorkerMainGui());
						    setVisible(true);
						}
				}
				
			}
		});
		/**
		 * worker change details button pressed
		 */
		updateWorker.getUpdateWdetails().getBtnChange().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = updateWorker.updateWorkerData();
				if(ans){
						if(userLogged.getPrivilage().equals("Worker")){
							getContentPane().add(main.getWorkerMainGui());
							setContentPane(main.getWorkerMainGui());
						    setVisible(true);
							}
						else if(userLogged.getPrivilage().equals("Manager")){
							getContentPane().add(main.getManagerMainGui());
							setContentPane(main.getManagerMainGui());
						    setVisible(true);
							}
						else if(userLogged.getPrivilage().equals("Secretary")){
							getContentPane().add(main.getSecMainGui());
							setContentPane(main.getSecMainGui());
						    setVisible(true);
							}
					}
				}
		});
		/**
		 * update password back button pressed
		 */
		updateWorker.getUpdateWpassword().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(userLogged.getPrivilage().equals("Worker")){
					getContentPane().add(main.getWorkerMainGui());
					setContentPane(main.getWorkerMainGui());
				    setVisible(true);
					}
				else if(userLogged.getPrivilage().equals("Manager")){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
				    setVisible(true);
					}
				else if(userLogged.getPrivilage().equals("Secretary")){
					getContentPane().add(main.getSecMainGui());
					setContentPane(main.getSecMainGui());
				    setVisible(true);
					}
			}
		});
		/**
		 * Manager main handle worker button pressed
		 */
		handleWorker.getHandleWorker().getBtnAddWorker().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleWorker.getAddWorker());
				setContentPane(handleWorker.getAddWorker());
			    setVisible(true);
			}
		});
		/**
		 * Manager main worker details button pressed
		 */
		handleWorker.getHandleWorker().getBtnWorkerDetails().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				ArrayList<User> allUsers = handleWorker.queryAllUsers();		
				getContentPane().add(handleWorker.getW_details());
				handleWorker.getW_details().setUsers(allUsers);
				setContentPane(handleWorker.getW_details());
			    setVisible(true);
			}
		});
		/**
		 * handle worker "worker details" back button pressed
		 */
		handleWorker.getW_details().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleWorker.getHandleWorker());
				setContentPane(handleWorker.getHandleWorker());
			    setVisible(true);
			}
		});
		/**
		 * Manager handle Worker back  button pressed
		 */
		handleWorker.getHandleWorker().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(main.getManagerMainGui());
				setContentPane(main.getManagerMainGui());
			    setVisible(true);
			}
		});
		/**
		 * handle Worker add worker button pressed
		 */
		handleWorker.getAddWorker().getBtnAdd().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = handleWorker.addWorker();
				if(ans){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
					setVisible(true);
					handleWorker.clearText();
				}
			}
		});
		/**
		 * add worker back button pressed
		 */
		handleWorker.getAddWorker().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handleWorker.clearText();
				getContentPane().add(handleWorker.getHandleWorker());
				setContentPane(handleWorker.getHandleWorker());
				setVisible(true);		
			}
		});
		/**
		 * remove worker back button pressed
		 */
		handleWorker.getRemoveWorker().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(handleWorker.getHandleWorker());
				setContentPane(handleWorker.getHandleWorker());
				setVisible(true);
			}
		});
		/**
		 * Handle worker remove worker button was pressed 
		 */
		handleWorker.getHandleWorker().getBtnRemoveWorker().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleWorker.getRemoveWorker());
				setContentPane(handleWorker.getRemoveWorker());
				ArrayList<User> userList = handleWorker.queryAllUsers();
				handleWorker.getRemoveWorker().setUsers(userList);
				setVisible(true);
			}
		});
		/**
		 * Handle worker change worker permission button was pressed 
		 */
		handleWorker.getHandleWorker().getBtnSetPermission().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				ArrayList<User> allUsers = handleWorker.queryAllUsers();
				
				getContentPane().add(handleWorker.getSetPerGUI());
				handleWorker.getSetPerGUI().setUsers(allUsers);
				setContentPane(handleWorker.getSetPerGUI());
				setVisible(true);		
			}
		});
		/**
		 * set permission change button was pressed
		 */
		handleWorker.getSetPerGUI().getBtnChange().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = handleWorker.updatePermission(String.valueOf(handleWorker.getSetPerGUI().getNewPermissioncomboBox().getSelectedItem()));
				if(ans){
					getContentPane().add(handleWorker.getHandleWorker());
					setContentPane(handleWorker.getHandleWorker());
					setVisible(true);
				}
				
				handleWorker.getSetPerGUI().getOldPermissiontextField().setText("");
			}
		});
		/**
		 * set permission Back button was pressed
		 */
		handleWorker.getSetPerGUI().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleWorker.getHandleWorker());
				setContentPane(handleWorker.getHandleWorker());
				setVisible(true);
			}
		});
		/**
		 * manager pressed remove worker
		 */
		handleWorker.getRemoveWorker().getBtnRemove().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = handleWorker.removeWorker();
				if(ans){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
					setVisible(true);		
				}
			}
		});
		/**
		 * manager handle customer button was pressed
		 */
		main.getManagerMainGui().getBtnHandlingCustomer().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
						
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);		
			}
		});
		/**
		 * // manager handle event button was pressed
		 */
		main.getManagerMainGui().getBtnEventHandling().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleEvent.getEveData());
				setContentPane(handleEvent.getEveData());
				ArrayList<Event> eDetails = handleEvent.getEventDetails();
				handleEvent.getEveData().setAllEvents(eDetails);
				setVisible(true);
			}
		});
		
		/**
		 * manager main ShiftsArrangement button was pressed
		 */
		main.getManagerMainGui().getBtnShiftArr().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleSchedule.getManagerShiftsArrangementGui());
				setContentPane(handleSchedule.getManagerShiftsArrangementGui());
			    setVisible(true);
			}
		});
		/**
		 * manager main Change Password button was pressed
		 */
		main.getManagerMainGui().getBtnChangePassword().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(updateWorker.getUpdateWpassword());
				setContentPane(updateWorker.getUpdateWpassword());
			    setVisible(true);
			}
		});
		/**
		 * manager main Update Details button was pressed
		 */
		main.getManagerMainGui().getBtnUpdateDetails().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				updateWorker.viewWorkerDetails();
				getContentPane().add(updateWorker.getUpdateWdetails());
				setContentPane(updateWorker.getUpdateWdetails());
			    setVisible(true);
			}
		});
		/**
		 * manager ShiftsArrangement view shifts button was pressed
		 */
		handleSchedule.getManagerShiftsArrangementGui().getBtnViewShifts().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					
				handleSchedule.getSchedule();
				getContentPane().add(handleSchedule.getScheduleGui());
				setContentPane(handleSchedule.getScheduleGui());
			    setVisible(true);
			}
		});
		/**
		 * manager ShiftsArrangement edit shifts button was pressed
		 */
		handleSchedule.getManagerShiftsArrangementGui().getBtnEditShifts().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
			
			ArrayList<Schedule> schedList = handleSchedule.getEventToSched();
			handleSchedule.getEditShiftGui().setSchedule(schedList);
			
			getContentPane().add(handleSchedule.getEditShiftGui());
			setContentPane(handleSchedule.getEditShiftGui());
			setVisible(true);
			
			
			}
		});
		/**
		 * Handle Schedule edit shift continue button was pressed 
		 */
		handleSchedule.getEditShiftGui().getBtnContinue().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
			
				
				ArrayList<User> allUserList = handleSchedule.getAllUsers();
				System.out.println("all user lis is empty? -" +allUserList.isEmpty());
				handleSchedule.getSetShiftGui().setWorkerList(allUserList);
				
				getContentPane().add(handleSchedule.getSetShiftGui());	
				setContentPane(handleSchedule.getSetShiftGui());
			    setVisible(true);
				
			}
		});
		/**
		 * Set Schedule set button was pressed 
		 */
		handleSchedule.getSetShiftGui().getBtnSet().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
			
				
				handleSchedule.addToSchedule();
				handleSchedule.clearText();
				getContentPane().add(handleSchedule.getManagerShiftsArrangementGui());	
				setContentPane(handleSchedule.getManagerShiftsArrangementGui());
			    setVisible(true);
			    
				
			}
		});
		/**
		 * Set Schedule back button was pressed 
		 */
		handleSchedule.getSetShiftGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
			
				getContentPane().add(handleSchedule.getEditShiftGui());	
				setContentPane(handleSchedule.getEditShiftGui());
			    setVisible(true);
				
			}
		});
		/**
		 * manager ShiftsArrangement back button was pressed
		 */
		handleSchedule.getManagerShiftsArrangementGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					
				getContentPane().add(main.getManagerMainGui());
				setContentPane(main.getManagerMainGui());
			    setVisible(true);
			}
		});
		/**
		 * secretary handle customer button was pressed
		 */
		main.getSecMainGui().getBtnHandlingCustomer().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);		
			}
		});
		/**
		 * secretary handle event button was pressed
		 */
		main.getSecMainGui().getBtnEventHandling().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					
				getContentPane().add(handleEvent.getEveData());
				setContentPane(handleEvent.getEveData());
				ArrayList<Event> eDetails = handleEvent.getEventDetails();
				handleEvent.getEveData().setAllEvents(eDetails);
				setVisible(true);	
			}
		});
			
		/**
		 * handle customer View Details button was pressed
		 */
		handelCust.getHandelCustGui().getBtnViewDetails().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				
				ArrayList<Customer> cList = handelCust.getAllCustomer();
				handelCust.getvCdetails().setAllCustomer(cList);
				handelCust.setuORvFlag(0);
				
				getContentPane().add(handelCust.getvCdetails());
				setContentPane(handelCust.getvCdetails());
				setVisible(true);		
			}
		});	
		/**
		 * meeting GUI ChangeInchargedManager button was pressed
		 */
		handelCust.getmGui().getBtnChangeInchargedManager().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				ArrayList<String> namesList =handelCust.getAllManagersNames();
				handelCust.getPassingManagerInchargeGui().setM_namesList(namesList);
				
				ArrayList<Meeting> mList = handelCust.getAllCustomerMeeting();
				handelCust.getPassingManagerInchargeGui().setAllMeeting(mList);
				
				getContentPane().add(handelCust.getPassingManagerInchargeGui());
				setContentPane(handelCust.getPassingManagerInchargeGui());
				setVisible(true);		
			}
		});	
		/**
		 * meeting GUI ChangeInchargedManager button was pressed
		 */
		handelCust.getPassingManagerInchargeGui().getBtnApplay().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				boolean ans = handelCust.changeManagerIncharge();
				if(ans){
					getContentPane().add(handelCust.getmGui());
					setContentPane(handelCust.getmGui());
					setVisible(true);
				}
			}
		});
		/**
		 * meeting GUI ChangeInchargedManager button was pressed
		 */
		handelCust.getPassingManagerInchargeGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {		
				getContentPane().add(handelCust.getmGui());
				setContentPane(handelCust.getmGui());
				setVisible(true);		
			}
		});
		
		/**
		 * View Customer Details back button was pressed
		 */
		handelCust.getvCdetails().getBtnBack().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				handelCust.clearText();
				handelCust.setuORvFlag(-1);
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);
			}
		});
		/**
		 * handle customer update Details button was pressed
		 */
		handelCust.getHandelCustGui().getBtnUpdateDetails().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ArrayList<Customer> cList = handelCust.getAllCustomer();
				handelCust.getUpdateCustGui().setAllCustomer(cList);
				getContentPane().add(handelCust.getUpdateCustGui());
				setContentPane(handelCust.getUpdateCustGui());
				setVisible(true);
			}
		});
		/**	
		 *  update Details Continue button was pressed
		 */
		handelCust.getUpdateCustGui().getBtnContinue().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					
				handelCust.setuORvFlag(1);
				handelCust.setCustomerDetails();
				getContentPane().add(handelCust.getNewCustomerDetailsGui());
				setContentPane(handelCust.getNewCustomerDetailsGui());
				setVisible(true);
			}
		});
		/**
		 *  NewCustomerDetailsGui change button was pressed
		 */
		handelCust.getNewCustomerDetailsGui().getBtnChange().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = handelCust.updateCustDetails();
				if(ans){
					handelCust.clearText();
					handelCust.setuORvFlag(-1);
					getContentPane().add(handelCust.getHandelCustGui());
					setContentPane(handelCust.getHandelCustGui());
					setVisible(true);
				}
			}
		});
		/**
		 *  NewCustomerDetailsGui back button was pressed
		 */
		handelCust.getNewCustomerDetailsGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getUpdateCustGui());
				setContentPane(handelCust.getUpdateCustGui());
				setVisible(true);
			}
		});
		/**
		 *  update Details back button was pressed
		 */
		handelCust.getUpdateCustGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				handelCust.clearText();
				handelCust.setuORvFlag(-1);
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);
			}
		});
		/**
		 * handle customer remove customer button was pressed
		 */
		handelCust.getHandelCustGui().getBtnRemoveCustomer().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getRemoveCustGui());
				setContentPane(handelCust.getRemoveCustGui());
				ArrayList<Customer> cList = handelCust.getAllCustomer();
				handelCust.getRemoveCustGui().setAllCustomer(cList);
				handelCust.setuORvFlag(2);
				setVisible(true);
			}
		});
		/**
		 *  remove customer remove button was pressed
		 */
		handelCust.getRemoveCustGui().getBtnRemove().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = handelCust.removeCustomer();
				if(ans){
					handelCust.clearText();
					handelCust.setuORvFlag(-1);
					getContentPane().add(handelCust.getHandelCustGui());
					setContentPane(handelCust.getHandelCustGui());
					setVisible(true);
				}
			}
		});
		/**
		 *  remove customer back button was pressed
		 */
		handelCust.getRemoveCustGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				handelCust.clearText();
				handelCust.setuORvFlag(-1);
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);
			}
		});
		/**
		 * handle customer Meeting button was pressed
		 */
		handelCust.getHandelCustGui().getBtnMeeting().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getNewOrReturnCustomerGui());
				setContentPane(handelCust.getNewOrReturnCustomerGui());
				setVisible(true);
			}
		});
		/**
		 *  Meeting edit meeting button was pressed
		 */
		handelCust.getmGui().getBtnEditMeeting().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				
				ArrayList<Meeting> allCustMeeting = handelCust.getAllCustomerMeeting();
				handelCust.getEditMeetingGui().setAllCustomersMeeting(allCustMeeting);
				getContentPane().add(handelCust.getEditMeetingGui());
				setContentPane(handelCust.getEditMeetingGui());
				setVisible(true);
			}
		});
		/**
		 * edit Meeting change button was pressed
		 */
		handelCust.getEditMeetingGui().getBtnChange().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				
				boolean ans = handelCust.editMeeting();
				if(ans){
					getContentPane().add(handelCust.getHandelCustGui());
					setContentPane(handelCust.getHandelCustGui());
					setVisible(true);
				}
			}
		});
		/**
		 * edit Meeting back button was pressed
		 */
		handelCust.getEditMeetingGui().getBtnBack().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(handelCust.getmGui());
				setContentPane(handelCust.getmGui());
				setVisible(true);
			}
		});
		/**
		 *  Meeting back button was pressed
		 */
		handelCust.getmGui().getBtnBack().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(handelCust.getNewOrReturnCustomerGui());
				setContentPane(handelCust.getNewOrReturnCustomerGui());
				setVisible(true);
			}
		});
		/**
		 * Handle customer add customer's back continue button was pressed 
		 */
		handelCust.getAddCustomerGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handelCust.setuORvFlag(3);
				handelCust.clearText();
				getContentPane().add(handelCust.getNewOrReturnCustomerGui());
				setContentPane(handelCust.getNewOrReturnCustomerGui());
				setVisible(true);
			}
		});
		/**
		 *  NewOrReturnCustomerGui back button was pressed 
		 */
		handelCust.getNewOrReturnCustomerGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);
			}
		});
		/**
		 *  Existing Customer button was pressed 
		 */
		handelCust.getNewOrReturnCustomerGui().getBtnExistingCustomer().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getHaveOrDontHaveEventGui());
				setContentPane(handelCust.getHaveOrDontHaveEventGui());
			
				setVisible(true);
			}
		});
		/**
		 *  HaveOrDontHaveEventGui HaveEvent button was pressed 
		 */
		handelCust.getHaveOrDontHaveEventGui().getBtnHaveEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getmGui());
				setContentPane(handelCust.getmGui());
			
				setVisible(true);
				
				
			}
		});
		/**
		 *  HaveOrDontHaveEventGui HaveEvent button was pressed 
		 */
		handelCust.getHaveOrDontHaveEventGui().getBtnDontGotEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

				getContentPane().add(handelCust.getCooMeeting());
				setContentPane(handelCust.getCooMeeting());
				
				ArrayList<String> managersName =handelCust.getAllManagersNames();
				handelCust.getCooMeeting().allManagers(managersName);
				ArrayList<Meeting> mangerList =handelCust.getMeetingForEvent();
				handelCust.getCooMeeting().allMeetingList(mangerList);
				
				setVisible(true);

			}
		});
		/**
		 *  HaveOrDontHaveEventGui back was pressed 
		 */
		handelCust.getHaveOrDontHaveEventGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getNewOrReturnCustomerGui());
				setContentPane(handelCust.getNewOrReturnCustomerGui());
			
				setVisible(true);
				
				
			}
		});
		/**
		 *  New Customer button was pressed 
		 */
		handelCust.getNewOrReturnCustomerGui().getBtnNewCustomer().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getAddCustomerGui());
				setContentPane(handelCust.getAddCustomerGui());
				handelCust.clearText();
				handelCust.setuORvFlag(-1);
				
				setVisible(true);
			}
		});
		/**
		 *  New Customer button was pressed 
		 */
		handelCust.getCoordWithExistingGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getHaveOrDontHaveEventGui());
				setContentPane(handelCust.getHaveOrDontHaveEventGui());
				setVisible(true);
			}
		});
		/**
		 * Meeting Coordinating Meeting button was pressed
		 */
		handelCust.getmGui().getBtnCoordinateMeeting().addActionListener(new ActionListener(){ 
			public void actionPerformed(ActionEvent e) {
			
				handelCust.clearText();
				handelCust.setuORvFlag(-1);
				getContentPane().add(handelCust.getCoordWithExistingGui());
				setContentPane(handelCust.getCoordWithExistingGui());
		
				ArrayList<String> managersName =handelCust.getAllManagersNames();
				handelCust.getCoordWithExistingGui().allManagers(managersName);
				ArrayList<Meeting> mangerList =handelCust.getAllCustIDs();
				handelCust.getCoordWithExistingGui().allMeetingList(mangerList);
				
				setVisible(true);
			}
		});
		/**
		 * CoordWithExistingGui Coordinate button was pressed
		 */
		handelCust.getCoordWithExistingGui().getBtnCoordinate().addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			boolean ans =  handelCust.coorditatingMeetingToExsitEvent();
				if(ans){
					getContentPane().add(handelCust.getHandelCustGui());
					setContentPane(handelCust.getHandelCustGui());
					setVisible(true);
				}
				
			}
		});
		
		/**
		 * Coordinating Meeting Coordinate button was pressed
		 */
		handelCust.getCooMeeting().getBtnCoordinate().addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			boolean ans =  handelCust.coorditatingMeetingToNewEvent();
				if(ans){
					getContentPane().add(handelCust.getHandelCustGui());
					setContentPane(handelCust.getHandelCustGui());
					setVisible(true);
				}
				
			}
		});
		/**
		 * handle customer back button was pressed
		 */
		handelCust.getHandelCustGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				if(userLogged.getPrivilage().equals("Manager")){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
					setVisible(true);
				}
				else if(userLogged.getPrivilage().equals("Secretary")){
					getContentPane().add(main.getSecMainGui());
					setContentPane(main.getSecMainGui());
					setVisible(true);
				}
			}
		});
		/**
		 * Add customer add button was pressed
		 */
		handelCust.getAddCustomerGui().getBtnAdd().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handelCust.setuORvFlag(3);
				boolean ans = handelCust.addNewCustomer();
				if(ans){
					
					getContentPane().add(handelCust.getCoordFromAddCustGui());
					setContentPane(handelCust.getCoordFromAddCustGui());
					
					ArrayList<String> managersName =handelCust.getAllManagersNames();
					handelCust.getCoordFromAddCustGui().allManagers(managersName);
					ArrayList<Meeting> mangerList =handelCust.getMeetingForEvent();
					handelCust.getCoordFromAddCustGui().allMeetingList(mangerList);
					setVisible(true);
				}
				handelCust.getCoordFromAddCustGui().getmTimetTxtField().setText("");
				handelCust.getCoordFromAddCustGui().getManagerInchargecomboBox().removeAllItems();
				
				
				
			}
		});
		/**
		 * CoordFromAddCustGui Coordinate button was pressed
		 */
		handelCust.getCoordFromAddCustGui().getBtnCoordinate().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handelCust.coorditatingMeetingToNewCust();
				
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);
			}
		});
		/**
		 * CoordFromAddCustGui Back button was pressed
		 */
		handelCust.getCoordFromAddCustGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelCust.getHandelCustGui());
				setContentPane(handelCust.getHandelCustGui());
				setVisible(true);
			}
		});
		/**
		 * Coordinating Meeting back button was pressed
		 */
		handelCust.getCooMeeting().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				handelCust.getCooMeeting().getmTimetTxtField().setText("");
				handelCust.getCooMeeting().getManagerInchargecomboBox().removeAllItems();;
		
				getContentPane().add(handelCust.getmGui());
				setContentPane(handelCust.getmGui());
				setVisible(true);
			}
		});
		/**
		 *  handle event cancel event button was pressed
		 */
		handleEvent.geteHandlinhGui().getBtnCancelEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean answer = handleEvent.checkNumberOfEvents();
				boolean ans = handleEvent.cancelEvent();
				if(ans){
					if(answer){
						ArrayList<Customer> c =handleEvent.CustomerDetailsToRemove();

						getContentPane().add(handelCust.getRemoveCustGui());
						setContentPane(handelCust.getRemoveCustGui());
						handelCust.getRemoveCustGui().setAllCustomer(c);
						setVisible(true);
						}
					else{
						getContentPane().add(main.getManagerMainGui());
						setContentPane(main.getManagerMainGui());
						setVisible(true);	
					}
				}	
			}
		});
		/**
		 *  handle event close event button was pressed
		 */
		handleEvent.geteHandlinhGui().getBtnCloseEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {	
				handleEvent.closeEvent();		
			}
		});
//		/**
//		 *  handle event pic video button was pressed
//		 */
//		handleEvent.geteHandlinhGui().getBtnPickVideo().addActionListener(new ActionListener() {
//			public void actionPerformed(ActionEvent e) {	
//				handleEvent.saveVideoPath();		
//			}
//		});

		/**
		 *  handle event create event button was pressed
		 */
		handleEvent.geteHandlinhGui().getBtnCreateEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleEvent.getCreatEvent());
				setContentPane(handleEvent.getCreatEvent());
				setVisible(true);		
			}
		});
		/**
		 *  create event button was pressed
		 */
		handleEvent.getCreatEvent().getBtnCreate().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handleEvent.createNewEvent();	
				getContentPane().add(main.getManagerMainGui());
				setContentPane(main.getManagerMainGui());
				setVisible(true);		
			}
		});	
		/**
		 *  create event button was pressed
		 */
		handleEvent.getCreatEvent().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleEvent.geteHandlinhGui());
				setContentPane(handleEvent.geteHandlinhGui());
			}
		});	
		
		/**
		 *  handle event edit event button was pressed
		 */
		handleEvent.geteHandlinhGui().getBtnEditEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
												
				getContentPane().add(handleEvent.getEditEv());
				setContentPane(handleEvent.getEditEv());
				setVisible(true);		
			}
		});
		/**
		 *  edit event change button was pressed
		 */
		handleEvent.getEditEv().getBtnChange().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				boolean ans = handleEvent.editEvent();
				if(ans){
					getContentPane().add(handleEvent.geteHandlinhGui());
					setContentPane(handleEvent.geteHandlinhGui());
					setVisible(true);
					handleEvent.getEditEv().getChckbxNewDate().setSelected(false);
					handleEvent.getEditEv().getChckbxNewPlace().setSelected(false);
					handleEvent.getEditEv().getPlaceTextField().setText("");
					handleEvent.getEditEv().getChckbxNewPlace().setSelected(false);
					handleEvent.getEditEv().getPlaceTextField().setText("");
					handleEvent.getEditEv().getChckbxPaied().setSelected(false);
				}
				
			}
		});
		/**
		 *  edit event back button was pressed
		 */
		handleEvent.getEditEv().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handleEvent.geteHandlinhGui());
					setContentPane(handleEvent.geteHandlinhGui());
					setVisible(true);
				
			}
		});
		/**
		 * event details continue button was pressed
		 */
		handleEvent.getEveData().getBtnContinue().addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				
				handleEvent.geteHandlinhGui().getBtnCreateEvent().setEnabled(true);
				handleEvent.geteHandlinhGui().getBtnCloseEvent().setEnabled(true);
				handleEvent.geteHandlinhGui().getBtnViewEvent().setEnabled(true);
				handleEvent.geteHandlinhGui().getBtnCancelEvent().setEnabled(true);
				handleEvent.geteHandlinhGui().getBtnEditEvent().setEnabled(true);
				handleEvent.geteHandlinhGui().getBtnPlayVideo().setEnabled(true);
				
				handleEvent.setEventData();
				boolean ans = handleEvent.isEventExists();
				if(ans)
					handleEvent.geteHandlinhGui().getBtnCreateEvent().setEnabled(false);
				else{
					handleEvent.geteHandlinhGui().getBtnCloseEvent().setEnabled(false);
					handleEvent.geteHandlinhGui().getBtnViewEvent().setEnabled(false);
					handleEvent.geteHandlinhGui().getBtnCancelEvent().setEnabled(false);
					handleEvent.geteHandlinhGui().getBtnEditEvent().setEnabled(false);
					handleEvent.geteHandlinhGui().getBtnPlayVideo().setEnabled(false);
				}
				handleEvent.setEventData();
				boolean answer = handleEvent.isEventOpen();
				System.out.println("answer "+answer);
				if(answer==false){
					
					handleEvent.geteHandlinhGui().getBtnCloseEvent().setEnabled(false);
					handleEvent.geteHandlinhGui().getBtnCancelEvent().setEnabled(false);
					handleEvent.geteHandlinhGui().getBtnEditEvent().setEnabled(false);
				}
				
				getContentPane().add(handleEvent.geteHandlinhGui());
				setContentPane(handleEvent.geteHandlinhGui());
				setVisible(true);		
		}
	});
		/**
		 *handle event back button was pressed
		 */
		handleEvent.geteHandlinhGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
												
				getContentPane().add(handleEvent.getEveData());
				setContentPane(handleEvent.getEveData());
				setVisible(true);		
			}
		});
		
//		/**
//		 *handle event play video button was pressed
//		 */
//		handleEvent.geteHandlinhGui().getBtnPlayVideo().addActionListener(new ActionListener() {
//			public void actionPerformed(ActionEvent e) {
//												
//				handleEvent.getVideoPath();		
//			}
//		});
		/**
		 * Handle event choose event's back button was pressed 
		 */
		handleEvent.getEveData().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(userLogged.getPrivilage().equals("Manager")){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
					setVisible(true);
				}
				else if(userLogged.getPrivilage().equals("Secretary")){
					getContentPane().add(main.getSecMainGui());
					setContentPane(main.getSecMainGui());
					setVisible(true);
				}	
				else if(userLogged.getPrivilage().equals("Worker")){
					getContentPane().add(main.getWorkerMainGui());
					setContentPane(main.getWorkerMainGui());
					setVisible(true);
				}	
			}
		});
		/**
		 *  view event back button was pressed
		 */
		handleEvent.getViewEventGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				getContentPane().add(handleEvent.geteHandlinhGui());
				setContentPane(handleEvent.geteHandlinhGui());
				setVisible(true);
			}
		});
		/**
		 *  handle event view event button was pressed
		 */
		handleEvent.geteHandlinhGui().getBtnViewEvent().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				handleEvent.viewEventDetails();
				getContentPane().add(handleEvent.getViewEventGui());
				setContentPane(handleEvent.getViewEventGui());
				setVisible(true);
			}
		});
		/**
		 * Manager main statistics button was pressed 
		 */
		main.getManagerMainGui().getBtnStatistics().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelReport.getEventsInPeriodGui());
				setContentPane(handelReport.getEventsInPeriodGui());
				setVisible(true);
			}
		});
		
		/**
		 *  statistics- EventsINPeriod button was pressed 
		 */
		handelReport.getStatisticsGui().getBtnEventsINPeriod().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(handelReport.getEventsInPeriodGui());
				setContentPane(handelReport.getEventsInPeriodGui());
				setVisible(true);
			}
		});
		/**
		 * EventsINPeriod's back button was pressed 
		 */
		handelReport.getEventsInPeriodGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(main.getManagerMainGui());
				setContentPane(main.getManagerMainGui());
				setVisible(true);	
			}
		});
		/**
		 *  Handle report-EventsInPeriodGui- generateReport button was pressed 
		 */
		handelReport.getEventsInPeriodGui().getBtnGenerateReport().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				handelReport.reportSetTime();
				System.out.println(handelReport.getEventsInPeriodGui().getTypeOfStatisticcomboBox().getSelectedItem().toString());
				if(handelReport.getEventsInPeriodGui().getTypeOfStatisticcomboBox().getSelectedItem().toString().equals("Event In Period"))
					{
						handelReport.eventsInPeriod();
					}
				else if(handelReport.getEventsInPeriodGui().getTypeOfStatisticcomboBox().getSelectedItem().toString().equals("Event In Halls"))
					{
						handelReport.getHolePerPetiod();
					}
				else if(handelReport.getEventsInPeriodGui().getTypeOfStatisticcomboBox().getSelectedItem().toString().equals("Meetings Statistics"))
				{
						//handelReport.MeetingPerPetiod();
				}
					
			}
		});
		/**
		 * getStatisticsGui - back button was pressed 
		 */
		handelReport.getStatisticsGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(main.getManagerMainGui());
				setContentPane(main.getManagerMainGui());
				setVisible(true);
			}
		});
		/**
		 * EditShiftGui - back button was pressed 
		 */
		handleSchedule.getEditShiftGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handleSchedule.clearText();
				getContentPane().add(handleSchedule.getManagerShiftsArrangementGui());
				setContentPane(handleSchedule.getManagerShiftsArrangementGui());
				setVisible(true);
			}
		});
		/**
		 * ScheduleGui - back button was pressed 
		 */
		handleSchedule.getScheduleGui().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(userLogged.getPrivilage().equals("Manager")){
					getContentPane().add(handleSchedule.getManagerShiftsArrangementGui());
					setContentPane(handleSchedule.getManagerShiftsArrangementGui());
					setVisible(true);
				}
				else if(userLogged.getPrivilage().equals("Worker")){
					getContentPane().add(main.getWorkerMainGui());
					setContentPane(main.getWorkerMainGui());
					setVisible(true);
				}
			}
		});
		
		/**
		 * UpdateWorker- UpdateWdetails back button was pressed 
		 */
		updateWorker.getUpdateWdetails().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(userLogged.getPrivilage().equals("Manager")){
					getContentPane().add(main.getManagerMainGui());
					setContentPane(main.getManagerMainGui());
					setVisible(true);
				}
				else if(userLogged.getPrivilage().equals("Worker")){
					getContentPane().add(main.getWorkerMainGui());
					setContentPane(main.getWorkerMainGui());
					setVisible(true);
				}
				else if(userLogged.getPrivilage().equals("Secretary")){
					getContentPane().add(main.getSecMainGui());
					setContentPane(main.getSecMainGui());
					setVisible(true);
				}
			}
		});
		
		/**
		 * secretary main UpdateWdetails button was pressed 
		 */
		main.getSecMainGui().getBtnChangePassword().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				getContentPane().add(updateWorker.getUpdateWpassword());
				setContentPane(updateWorker.getUpdateWpassword());
				setVisible(true);

			}
		});
		
		/**
		 * secretary main UpdatePassword button was pressed 
		 */
		main.getSecMainGui().getBtnUpdateDetails().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				updateWorker.viewWorkerDetails();
				getContentPane().add(updateWorker.getUpdateWdetails());
				setContentPane(updateWorker.getUpdateWdetails());
				setVisible(true);
			}
		});
		/**
		 * secretary main finished email button was pressed 
		 */
		handelCust.getNotifyCust().getBtnFinishedEmail().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
				ArrayList<Customer> cList = handelCust.getAllCustomer();
				handelCust.getMailToCustomerGui().setAllCustomer(cList);
				handelCust.setuORvFlag(4);
				
				getContentPane().add(handelCust.getMailToCustomerGui());
				setContentPane(handelCust.getMailToCustomerGui());
				setVisible(true);
			}
		});
		handelCust.getMailToCustomerGui().getBtnSend().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				handelCust.sentMailTocust();
				handelCust.clearText();
				handelCust.setuORvFlag(-1);
			}
		});	
				
		/**
		 * Secretary main NotifyCustomer button was pressed
		 */
		main.getSecMainGui().getBtnNotifyCustomer().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(handelCust.getNotifyCust());
				setContentPane(handelCust.getNotifyCust());
				setVisible(true);
			}
		});
		/**
		 * NotifyCustomer Back button was pressed
		 */
		handelCust.getNotifyCust().getBtnBack().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getContentPane().add(main.getSecMainGui());
				setContentPane(main.getSecMainGui());
				setVisible(true);
			}
		});
	}
	/**
	* Get the only singleton connection
	* This method is read with initial parameters
	* @param s The host to connect to.
	* @param port The port to connect to.
	* @return client instance
	* 
	*/
	public static ClientConsole getConnection(String s, int port)

	{
		if(client== null){
			client = new ClientConsole(s, port);
		}
		return client;
		
	}
    	
	/**
	* Get the only singleton connection
	* This method is read without parameters
	* so the connection is the same as before
	* @return client instance
	*/
	
	public static ClientConsole getConnection() {
		return client;
	}
	/**
	*@return userLogged instance
	*/
	public static User getUserLogged(){
		return userLogged;
	}

}
	